package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.domain.SuccessCode;
import com.atguigu.jxc.service.GoodsTypeService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author tongatong
 * @name GoodsTypeController
 * @description
 * @date 2021/10/15
 * @time 11:27
 */
@RestController
@RequestMapping("/goodsType")
public class GoodsTypeController {
    @Resource
    private GoodsTypeService goodsTypeService;

    @PostMapping("/loadGoodsType")
    public String loadGoodsType() {

        return goodsTypeService.loadGoodsType();
    }
    @PostMapping("/save")
    public ServiceVO<Void> save(String  goodsTypeName, Integer pId) {
        goodsTypeService.save(goodsTypeName, pId);
        return new ServiceVO<>(SuccessCode.SUCCESS_CODE, SuccessCode.SUCCESS_MESS);
    }
    @PostMapping("/delete")
    public ServiceVO<Void> delete(Integer goodsTypeId) {
        goodsTypeService.delete(goodsTypeId);
        return new ServiceVO<>(SuccessCode.SUCCESS_CODE, SuccessCode.SUCCESS_MESS);
    }
}
